package com.whpost.service.dao.stamp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.whpost.service.entity.stamp.StampHd;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author YinZhuoyi
 * @since 2024-04-11
 */
public interface StampHdMapper extends BaseMapper<StampHd> {

    @Select("select * from stamp_hd where ${ew.sqlSegment}")
    @Results(id="stamp_hd_map",value = {
            @Result(column="xm_id",property="stampXm",
                    one=@One(
                            select="com.whpost.service.dao.stamp.StampXmMapper.selectById")
            ),
            @Result(column="xm_id",property="xmId"),
            @Result(column="lx_id",property="stampHdLx",
                    one=@One(
                            select="com.whpost.service.dao.stamp.StampHdLxMapper.selectById")
            ),
            @Result(column="lx_id",property="lxId")
    })
    IPage<StampHd> getHdIPage(Page<StampHd> page,@Param("ew") QueryWrapper wrapper);

    @Select("select * from stamp_hd where id=#{0}")
    @ResultMap(value="stamp_hd_map")
    StampHd getById(Long id);

    @Select("select * from stamp_hd where xm_id=#{1} and rownum=1")
    StampHd getOneByXm(String xm_id);

    @Select("select id from stamp_hd where name like concat(concat('%',#{1}),'%') and state='1'")
    List<String> getIdList(String cxtj);

    @Select("select * from stamp_hd where ${ew.sqlSegment}")
    @ResultMap(value="stamp_hd_map")
    List<StampHd> getList(@Param("ew") QueryWrapper wrapper);

}
